﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EBA.IoC;

namespace EBA.Data
{
    /// <summary>
    /// 数据引用检测器
    /// </summary>
    public static class DataReferenceDetector
    {
        public static bool Detect<TDataReference>(string id) where TDataReference : IDataReference
        {
            var dataReferences = DataReferenceDetector.GetDataReferences<TDataReference>();

            foreach (var dataReference in dataReferences)
            {
                if (dataReference.Detect(id))
                {
                    return true;
                }
            }

            return false;
        }

        public static void Transform<TDataReference>(string from, string to) where TDataReference : IDataReference
        {
            var dataReferences = GetDataReferences<TDataReference>();

            foreach (var dataReference in dataReferences)
            {
                dataReference.Transform(from, to);
            }
        }

        static IEnumerable<TDataReference> GetDataReferences<TDataReference>() where TDataReference : IDataReference
        {
            throw new NotImplementedException();
        }
    }
}
